home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / Kubuntu 8.10 / kubuntu-8.10-desktop-i386.iso / casper / filesystem.squashfs / etc / init.d / cron < prev    next >
Text File  |  2008-09-09  |  3KB  |  78 lines

  1. #!/bin/sh
  2. # Start/stop the cron daemon.
  3. #
  4. ### BEGIN INIT INFO
  5. # Provides:          cron
  6. # Required-Start:    $remote_fs $syslog $time
  7. # Required-Stop:     $remote_fs $syslog $time
  8. # Default-Start:     2 3 4 5
  9. # Default-Stop:      1
  10. # Short-Description: Regular background program processing daemon
  11. # Description:       cron is a standard UNIX program that runs user-specified 
  12. #                    programs at periodic scheduled times. vixie cron adds a 
  13. #                    number of features to the basic UNIX cron, including better
  14. #                    security and more powerful configuration options.
  15. ### END INIT INFO
  16.  
  17.  
  18. test -f /usr/sbin/cron || exit 0
  19.  
  20. PIDFILE=/var/run/crond.pid
  21. # In some systems the pidfile might be (incorrectly) set to /etc
  22. # if this pidfile is present, use it instead.
  23. [ -e /etc/cron.pid ] && PIDFILE=/etc/crond.pid
  24. [ -r /etc/default/cron ] && . /etc/default/cron
  25.  
  26. . /lib/lsb/init-functions
  27.  
  28. # Read the system's locale and set cron's locale. This locale
  29. # will be inherited by cron (used to set charset of emails)
  30. # and tasks running under it.
  31.  
  32. parse_environment () 
  33. {
  34.     ENV_FILE="none"
  35.     [ -r /etc/environment ] && ENV_FILE="/etc/environment"
  36.     [ -r /etc/default/locale ] && ENV_FILE="/etc/default/locale"
  37.     [ $ENV_FILE = none ] && return
  38.  
  39.     for var in LANG LC_ALL LC_CTYPE; do
  40.         value=$(egrep "^[^#]*${var}=" $ENV_FILE | tail -n1 | cut -d= -f2)
  41.         eval $var=$value
  42.     done
  43. }
  44.  
  45. # Parse the system's environment
  46. if [ "$READ_ENV" = "yes" ] ; then
  47.     export LANG LC_ALL LC_CTYPE
  48.     parse_environment
  49. fi
  50.  
  51.  
  52. case "$1" in
  53. start)    log_daemon_msg "Starting periodic command scheduler" "crond"
  54.         start-stop-daemon --start --quiet --pidfile $PIDFILE --name cron --startas /usr/sbin/cron -- $LSBNAMES $EXTRA_OPTS
  55.         log_end_msg $?
  56.     ;;
  57. stop)    log_daemon_msg "Stopping periodic command scheduler" "crond"
  58.         start-stop-daemon --stop --quiet --pidfile $PIDFILE --name cron
  59.         log_end_msg $?
  60.         ;;
  61. restart) log_daemon_msg "Restarting periodic command scheduler" "crond" 
  62.         start-stop-daemon --stop --retry 5 --quiet --pidfile $PIDFILE --name cron
  63.         start-stop-daemon --start --quiet --pidfile $PIDFILE --name cron --startas /usr/sbin/cron -- $LSBNAMES $EXTRA_OPTS
  64.         log_end_msg $?
  65.         ;;
  66. reload|force-reload) log_daemon_msg "Reloading configuration files for periodic command scheduler" "crond"
  67.     # cron reloads automatically
  68.         log_end_msg 0
  69.         ;;
  70. status)
  71.     status_of_proc -p $PIDFILE /usr/sbin/cron cron && exit 0 || exit $?
  72.     ;;
  73. *)    log_action_msg "Usage: /etc/init.d/cron {start|stop|restart|reload|force-reload|status}"
  74.         exit 2
  75.         ;;
  76. esac
  77. exit 0
  78.